package com.ujoku.service.admin.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.labillusion.core.database.base.mybatis.dao.BaseDao;
import com.labillusion.core.database.base.mybatis.service.base.impl.BaseServiceImpl;
import com.ujoku.context.constants.ContextConstants;
import com.ujoku.dao.admin.ParametersDao;
import com.ujoku.domain.admin.Parameter;
import com.ujoku.service.admin.ParametersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by Greg.Chen on 14-11-1.
 */
@Service
public class ParametersServiceImpl extends BaseServiceImpl<Parameter> implements ParametersService<Parameter> {

    @Autowired
    private ParametersDao dao;

    @Override
    protected BaseDao<Parameter> getBaseDao() {
        return this.dao;
    }

    @Override
    public Parameter getParameterByKey(String key){

        return dao.getParameterByKey(key);
    }



    @Override
    public List<Parameter> getUpgradeList(){
        List<Parameter> list = new ArrayList<>();
        for(int i=0;i< 3; i++){
            Parameter p =this.getParameterByKey(ContextConstants.MEMBER_UPGRADE + i);
            if(p != null)
                list.add(p);
        }

        return list;
    }
}
